package stu.sup.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import stu.sup.dto.MerProductDTO;
import stu.sup.entity.*;

import java.util.List;

public interface MerchantsProductMapper {
    int countByExample(MerchantsProductExample example);

    int deleteByExample(MerchantsProductExample example);

    int insert(MerchantsProduct record);

    int insertSelective(MerchantsProduct record);

    List<MerchantsProduct> selectByExample(MerchantsProductExample example);

    int updateByExampleSelective(@Param("record") MerchantsProduct record, @Param("example") MerchantsProductExample example);

    int updateByExample(@Param("record") MerchantsProduct record, @Param("example") MerchantsProductExample example);


    /**
     * 查出商家有哪些商品
     */
//    List<Product> findALLProductByMerchantId(Merchants merchants);
    List<MerProductDTO> findALLProductByMerchantId(Integer merchantsId);

    /**
     * 查出产品出自哪个商家
     *
     */
    @Select("select mi.merchants_shop from merchants_info mi join merchants m on mi.merchants_id = m.id join merchants_product mp on m.id = mp.merchants_id join product p on mp.product_id = p.id and p.id = #{id}")
    MerchantsInfo findMerchantByProductId(Integer id);
}